﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace QuanLyKhachHang.DAO
{
    #region using
    using System.Data;
    using QuanLyKhachHang.DTO;
    using System.Data.OleDb;
    #endregion
    public class KH_LONDAO : ExcelDataProvider
    {
        public KH_LONDAO(String strPath): base(strPath)
		{
		}

        ~KH_LONDAO()
		{
			base.Dispose();
		}

		public DataSet ImportKhachHangLon(string sheetname)
		{
			DataSet ds;
			try
			{
				ds = new DataSet();
                base.sql = "select * from [" + sheetname + "]";
				base.FillDataSet(ref ds, "KhachHang");
				return ds;
			}
			catch(System.Exception e)
			{
				throw new Exception(e.Message, e.InnerException);
			}
		}

        public string[] GetExcelSheetNames()
        {
            DataTable dt = null;
            base.OpenConnection();
            dt = objConnection.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);

            if (dt == null)
            {
                return null;
            }

            String[] excelSheetNames = new String[dt.Rows.Count];
            int i = 0;

            foreach (DataRow row in dt.Rows)
            {
                excelSheetNames[i] = row["TABLE_NAME"].ToString();
                i++;
            }

            return excelSheetNames;
        }
    }
}
